package com.lzh.lzhblog.controller;

import com.lzh.lzhframework.annotation.LogAnnotation;
import com.lzh.lzhframework.constants.LogType;
import com.lzh.lzhframework.domain.ResponseResult;
import com.lzh.lzhframework.domain.dto.feedback.AddFeedbackDto;
import com.lzh.lzhframework.domain.dto.feedback.QueryFeedbackDto;
import com.lzh.lzhframework.domain.dto.feedback.QueryMyFeedbackDto;
import com.lzh.lzhframework.domain.vo.feedback.FeedbackStatusVo;
import com.lzh.lzhframework.domain.vo.feedback.FeedbackTypeVo;
import com.lzh.lzhframework.service.FeedbackService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @Author luzhiheng
 * @Date 2023/11/27 11:27
 */
@RequestMapping("/feedback")
@RestController
public class FeedBackController {

    @Resource
    private FeedbackService feedbackService;

    @LogAnnotation(message = "用户反馈", operation = LogType.ADD)
    @PostMapping("/addFeedback")
    public ResponseResult addFeedback(@Valid @RequestBody AddFeedbackDto dto) {
        feedbackService.addFeedback(dto);
        return ResponseResult.success();
    }

    @LogAnnotation(message = "查询我的反馈", operation = LogType.QUERY)
    @PostMapping("/queryMyFeedbackPage")
    public ResponseResult queryMyFeedbackPage(@Valid @RequestBody QueryMyFeedbackDto dto) {
        return feedbackService.queryMyFeedbackPage(dto);
    }

    @LogAnnotation(message = "查询所有反馈状态", operation = LogType.QUERY)
    @GetMapping("/queryFeedbackStatus")
    public ResponseResult queryFeedbackStatus() {
        List<FeedbackStatusVo> feedbackStatusVoList = feedbackService.queryFeedbackStatus();
        return ResponseResult.success(feedbackStatusVoList);
    }

    @LogAnnotation(message = "查询所有反馈类型", operation = LogType.QUERY)
    @GetMapping("/queryFeedbackType")
    public ResponseResult queryFeedbackType() {
        List<FeedbackTypeVo> feedbackType = feedbackService.queryFeedbackType();
        return ResponseResult.success(feedbackType);
    }
}
